<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>禁用管理</title>
    <#assign base=request.contextPath  />
    <base id="basePath" href="${base}">
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css">
    <script src="${base}/frame/layui/layui.js" charset="utf-8"></script>
    <script src="${base}/js/jquery/jquery.min.js"></script>
    <script src="${base}/js/zhang.js"></script>
</head>
<body>
<#--<form class="layui-form" action="" style="padding-top: 20px;">-->
    <#--<div class="demoTable" >-->
        <#--<div class="layui-form-item">-->

            <#--<div class="layui-inline"  >-->
                <#--<label class="layui-form-label">绑定状态</label>-->
                <#--<div class="layui-input-inline">-->
                    <#--<select id="status" lay-verify="">-->
                        <#--<option value="">请选择</option>-->
                        <#--<option value="已绑定">已绑定</option>-->
                        <#--<option value="未绑定">未绑定</option>-->
                    <#--</select>-->
                <#--</div>-->

            <#--</div>-->

            <#--<button class="layui-btn" onclick="search()" data-method="offset" type="button"-->
                    <#--style="background-color: #0092EF; margin-left: 25px">查询-->
            <#--</button>-->

        <#--</div>-->
    <#--</div>-->
<#--</form>-->
<div class="demoTable"style="padding:15px;">
    <button class="layui-btn" id="btn2" data-method="offset"  type="button" style="background-color: #0092EF;">禁用号段</button>
</div>
<table class="layui-hide" id="test"  lay-filter="test"></table>
<script type="text/html" id="barDemo">
    <button type="button" onclick="deleteArea('{{d.id}}')" class="layui-btn layui-btn-sm layui-btn-normal" lay-event="del" style="background: red">删除</button>
</script>
<script>
    layui.use(['form', 'layedit', 'laydate', 'table', 'carousel'], function () {

        var carousel = layui.carousel;
        var form = layui.form
                , $ = layui.jquery
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                , table = layui.table;



        table.render({
            elem: '#test'
            ,url:'${base}/user/selectByStatus'
            ,title: '用户'
            ,totalRow: true
            ,toolbar: '#toolbarDemo'//打印
            ,cols:[[
                {field:'id', title: '序号',templet:function(val){
                        return val.LAY_INDEX
                    }, field: true,align:'center'}
                ,{field:'tel', title: '号段', align:'center'}
                , {fixed: 'right', title: '操作',  toolbar: '#barDemo', align: 'center'}
            ]]
            ,id:'testReload'
            ,page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                ,theme: '#0092EF'
                ,limit:10
            }

        });
        var active = {
            offset: function (othis) {
                var type = othis.data('type')
                        , text = othis.text();
                layer.open({
                    type: 2,
                    title: '禁用号段',
                    area: ['400px', '200px'], //高 宽
                    shadeClose: false,
                    //弹出的页面路径
                    content: '${base}/user/jin_add.html',//路径

                });
            }
        };

        $('#btn2').on('click', function(){
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });




    });


    //删除
    function deleteArea(id) {
        layer.confirm('确定删除?', function (index) {
        var jsonDate = {};
        jsonDate.id = id;

            $.ajax({
                type: "POST", //提交方式
                contentType: "application/json;charset=UTF-8",
                url: "${base}/user/qi",
                data: JSON.stringify(jsonDate),
                sync:false,
                success: function (data) {
                    if (data.code ===0){
                        layer.msg("删除成功")
                        var table = layui.table;
                        //表刷新方法
                        table.reload('testReload', {
                            url: '${base}/user/selectByStatus'
                            , where: {} //设定异步数据接口的额外参数
                        });
                        //关闭删除是否删除的提示框
                        layer.close(index);
                    } else {
                        layer.msg(data.msg)
                    }
                }
            });
        });
    }





</script>
</body>
</html>